<%@ page pageEncoding="UTF-8" %>
<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="门店申请列表"/>
  <c:param name="body">

    <div class="content-title">门店申请列表
      <p>${message.msg}</p>
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message.msg}</div>
      </c:if>
      <p></p>

      <div class="col-sm-5 col-sm-offset-1">
        <form id="searchForm" method="get" action="/system/apply/list"
              name="complaint">
          <div class="input-group pull-left" style="margin-bottom:8px;">
            查询：<a class="btn btn-primary btn-xs" href="/system/apply/list?acceptResult=1">通过</a>
            <a class="btn btn-primary btn-xs" href="/system/apply/list?acceptResult=2">拒绝</a>
          </div>
          <div class="input-group">
            <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


          </div>
        </form>
      </div>

      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>申请人</th>
            <th>申请理由</th>
            <th>申请时间</th>
            <th>门店</th>
            <%--<c:if test="${apply.handleResult != 0}">
            <th>处理人</th>
            <th>处理时间</th>
            </c:if>--%>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${pager.list}" var="apply">
            <tr class="success">
              <td><a href="#" onclick="showUser('<c:url
                      value="/system/user/getUser?id=${apply.applyUserId}"/>')" data-toggle="modal"
                     data-target="#showUser">${apply.applyUser}</a></td>
              <td>${apply.applyReason}</td>
              <td>${apply.time}</td>
              <td><a href="#" onclick="showShop('<c:url
                      value="/system/apply/getShop?id=${apply.shopId}"/>')" data-toggle="modal"
                     data-target="#showShop">${apply.applyShopName}</a></td>
              <%--<c:if test="${apply.handleResult != 0}">--%>
                <%--<td>${apply.handlerUser}</td>--%>
                <%--<td>${apply.handleTime}</td>--%>
              <%--</c:if>--%>
              <td>
                <c:if test="${apply.handleResult == 2}">
                  <a class="btn btn-primary btn-xs" href="#" onclick="show('<c:url
                          value="/system/apply/getApply?id=${apply.id}"/>')" data-toggle="modal"
                     data-target="#show">已审核拒绝</a>
                </c:if>
                <c:if test="${apply.handleResult == 1}">
                  <a class="btn btn-primary btn-xs" href="#" onclick="show('<c:url
                          value="/system/apply/getApply?id=${apply.id}"/>')" data-toggle="modal"
                     data-target="#show">已审核通过</a>
                </c:if>
                <c:if test="${apply.handleResult == 0}">
                  <a class="btn btn-primary btn-xs"
                     href="/system/apply/verify?id=${apply.id}&handle=1&shopId=${apply.shopId}&applyUserId=${apply.applyUserId}">通过
                  </a>
                  <a class="btn btn-primary btn-xs"
                     href="/system/apply/verify?id=${apply.id}&handle=2&shopId=${apply.shopId}&applyUserId=${apply.applyUserId}">拒绝
                  </a>
                </c:if>
              </td>
            </tr>
          </c:forEach>
          </tbody>
        </table>
      </div>
      <div class="row">
        <div class="col-sm-12">
            ${pager}
        </div>
      </div>
    </div>
    <script type="text/javascript">

      function showUser(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (user) {
            $('#username').html(user.username);
            $('#edit_mobile').html(user.mobile);
            $('#edit_email').html(user.email);
            $('#edit_realName').html(user.realName);
          }
        });
      }

      function showShop(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (shop) {
            $("#edit_name").html(shop.name);
            $('#edit_description').html(shop.description);
            $('#edit_createTime').html(shop.createTime);
            if(shop.state == "0")
            $('#edit_state').html("未被申请");
            else if(shop.state == "1")
              $('#edit_state').html("已被申请");
          }
        });
      }

      function show(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (apply) {
            $("#handlerUser").html(apply.handlerUser);
            $('#handleTime').html(apply.handleTime);
          }
        });
      }
    </script>
    <%--显示申请人详细信息模态框--%>
    <div class="modal fade" id="showUser" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">详细内容</h3>
          </div>
          <div class="modal-body">
            <div class="form-group">
              <label class="control-label" for="username">用户名</label>
              <span class="form-control" id="username" ></span>
            </div>
            <div class="form-group">
              <label for="edit_mobile">手机号</label>
              <span class="form-control" id="edit_mobile"></span>
            </div>
              <div class="form-group">
                  <label for="edit_email">邮箱</label>
                  <span class="form-control" id="edit_email"></span>
              </div>
            <div class="form-group">
              <label for="edit_realName">真实名字</label>
              <span class="form-control" id="edit_realName"></span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <%--显示门店详细信息模态框--%>
    <div class="modal fade" id="showShop" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">详细内容</h3>
          </div>
          <div class="modal-body">
            <div class="form-group">
              <label class="control-label">店名</label>
              <span  class="form-control" id="edit_name" />
            </div>
            <div class="form-group">
              <label >门店描述</label>
              <span class="form-control" id="edit_description"></span>
            </div>

            <div class="form-group">
              <label >创建时间</label>
              <span class="form-control" id="edit_createTime"></span>
            </div>
            <div class="form-group">
              <label>门店状态</label>
              <span class="form-control" id="edit_state"></span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="modal fade" id="show" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
          </div>
          <div class="modal-body">
            <div class="form-group">
              <label class="control-label">操作员</label>
              <span class="form-control" id="handlerUser" ></span>
            </div>
            <div class="form-group">
              <label >审核时间</label>
              <span class="form-control" id="handleTime"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
